package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class BorrowOperation implements Operation {
    @Override
    public void work(BookList bookList) {
        Scanner scan = new Scanner(System.in);
        System.out.println("借阅图书->");
        System.out.println("请输入要借阅的书名->");
        String name = scan.next();
        int tmp =bookList.getUsedSize();
        for (int i = 0; i < tmp; i++) {
            Book book = bookList.getBooks(i);
            if(name.equals(book.getName())) {
                bookList.getBooks(i).setBorrow(false);
                System.out.println("借阅成功！");
                System.out.println(bookList.getBooks(i).toString());
                return;
            }
        }
        System.out.println("找不到这本书");
    }
}
